//
//  ZJHeadView.swift
//  mini
//
//  Created by Mac on 2017/5/22.
//  Copyright © 2017年 Mac. All rights reserved.
//

import UIKit
import SnapKit

class ZJHeadView: UITableViewHeaderFooterView {

    var desLable:UILabel?
    
    var headerStr:String?{
        didSet{
            
            desLable?.text = headerStr
            
            desLable?.font = UIFont.systemFont(ofSize: 15)
        }
    }
    
    class func headerViewWithTableView(tableView:UITableView)->ZJHeadView{
        
        //1. 定义重用的标识
        let reuseId:String = "header";
        
        var headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: reuseId);
        
        if (headerView==nil) {
            
            headerView =  ZJHeadView(reuseIdentifier: reuseId)
        }
        
        return headerView as! ZJHeadView;
        
    }
    
    override init(reuseIdentifier: String?) {
        
      super.init(reuseIdentifier: reuseIdentifier)
      
        contentView.backgroundColor = kGlobelBgColor;
        
        desLable = UILabel()
        
        desLable?.textColor = UIColor.cz_color(withHex: 0xadacac);
        
        desLable?.textAlignment = .center;
        
        contentView.addSubview(desLable!)
        
        setupContrast()    
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupContrast()  {
        
        desLable?.snp.makeConstraints({ (make) in
            
            make.bottom.equalTo(contentView.snp.bottom).offset(-5);
            
            make.leading.equalTo(contentView).offset(20);
        })
    }

}
